<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/WEB-INF/jsp/teacher/common/header.jsp" %>
<div class="clearfix"></div>
<div class="row">
    <div class="col-md-12">
        <div class="x_panel">
            <div class="x_title">
                <h2>
                    查询教师信息<i class="fa fa-user"></i>
                    <small>${teacher.name}
                        - 您可以通过搜索或者其他的筛选项对教师的信息进行修改、删除等管理操作。^_^
                    </small>
                </h2>
                <div class="clearfix"></div>
            </div>
            <div class="x_content">
                <form method="post" action="${pageContext.request.contextPath }/admin/showTeacher">
                    <input type="hidden" id="pageNum" name="pageNum" />
                    <ul>
                        <li>
                            <div class="form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12">教师姓名</label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <input name="name" type="text" class="form-control col-md-7 col-xs-12">
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12">教师性别</label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <select name="sex" class="form-control">
                                            <option value="">--请选择--</option>
                                            <option value="0">男</option>
                                            <option value="1">女</option>
                                    </select>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12">所在学院</label>
                                <div class="col-md-6 col-sm-6 col-xs-12">
                                    <select id="college" name="college" class="form-control">
                                            <option value="" selected="selected">--请选择--</option>
                                            <c:forEach var="colleges" items="${colleges}">
                                                <option value="${colleges.college}">${colleges.college}</option>
                                            </c:forEach>
                                    </select>
                                </div>
                            </div>
                        </li>
                        <li></li>
                        <li>
                            <button type="submit" class="btn btn-primary"> 查 &nbsp;&nbsp;&nbsp;询</button>
                        </li>
                        <li>
                            <button type="button" onclick="reset()" class="reset btn btn-primary"> 重&nbsp;&nbsp;&nbsp;置</button>
                        </li>
                    </ul>
                </form>
            </div>
        </div>
    </div>
    <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
            <div class="x_content">
                <p class="text-muted font-13 m-b-30"></p>
                <div id="datatable-responsive_wrapper"
                     class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                    <div class="row">
                        <div class="col-sm-12">
                            <a href="${pageContext.request.contextPath}/admin/toAddTeacher"
                               class="btn btn-success btn-sm">添加教师</a>
                            <div style="color: red">${error}</div>
                            <table id="datatable-responsive"
                                   class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"
                                   cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info"
                                   style="width: 100%;">
                                <thead>
                                <tr role="row">
                                    <th class="sorting_asc" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        aria-label="First name: activate to sort column descending"
                                        aria-sort="ascending">教师工号
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        aria-label="Last name: activate to sort column ascending">
                                        姓名
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        aria-label="Last name: activate to sort column ascending">
                                        联系电话
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        aria-label="Last name: activate to sort column ascending">
                                        所在学院
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        aria-label="Last name: activate to sort column ascending">
                                        教师类型
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        aria-label="Last name: activate to sort column ascending">
                                        性别
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        aria-label="Last name: activate to sort column ascending">
                                        类型
                                    </th>
                                    <th class="sorting" tabindex="0"
                                        aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                        style="width: 124px;"
                                        aria-label="Last name: activate to sort column ascending">
                                        操作
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach var="pageInfo" items="${pageInfo.list}">
                                    <tr role="row" class="odd">
                                        <td tabindex="0" class="sorting_1">${pageInfo.teacherId}</td>
                                        <td>${pageInfo.name}</td>
                                        <td>${pageInfo.mobilePhone}</td>
                                        <td>${pageInfo.college}</td>
                                        <td>${pageInfo.teacherType}</td>
                                        <td>
                                            <c:if test="${pageInfo.sex=='0'}">男</c:if>
                                            <c:if test="${pageInfo.sex=='1'}">女</c:if>
                                        </td>
                                        <td>
                                            <c:if test="${pageInfo.type=='1'}">
                                                <label style="color: #00aeef">该账号被冻结</label>
                                            </c:if>
                                            <c:if test="${pageInfo.type=='2'}">普通用户</c:if>
                                            <c:if test="${pageInfo.type=='3'}">管理员</c:if>
                                        </td>
                                        <td>
                                            <div class="btn-group">
                                                 <button type="button" class="btn btn-danger dropdown-toggle"
                                                         data-toggle="dropdown" aria-expanded="false">
                                                     点击操作
                                                     <span class="caret"></span>
                                                     <span class="sr-only">Toggle Dropdown</span>
                                                 </button>
                                                <ul class="dropdown-menu" role="menu">
                                                    <c:choose>
                                                        <c:when test="${pageInfo.type==1}">
                                                            <li>
                                                                <a href="${pageContext.request.contextPath }/admin/updateType?stuId=${pageInfo.id}">解除冻结</a>
                                                            </li>
                                                            <li>
                                                                <a href="${pageContext.request.contextPath }/admin/delTeacher?id=${pageInfo.id}">删除</a>
                                                            </li>
                                                        </c:when>
                                                        <c:otherwise>
                                                            <li>
                                                                <a href="${pageContext.request.contextPath }/admin/toUpdate?teacherId=${pageInfo.teacherId}">修改</a>
                                                            </li>
                                                            <li>
                                                                <a href="${pageContext.request.contextPath }/admin/delTeacher?id=${pageInfo.id}">删除</a>
                                                            </li>
                                                        </c:otherwise>
                                                    </c:choose>
                                                </ul>
                                            </div>
                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-5">
                            <div class="dataTables_info" id="datatable-responsive_info"
                                 role="status" aria-live="polite">
                                共${pageInfo.totalCount}条记录${pageInfo.pageNum}/${pageInfo.totalPages}页
                                页码:
                                <c:forEach var="numb" items="${pageInfo.numb}">
                                    <a <c:if test="${pageInfo.pageNum==numb}">style="color: red"</c:if> href="javascript:page_nav(document.forms[0],${numb});">${numb}&nbsp;</a>
                                </c:forEach>
                            </div>
                        </div>

                        <div class="col-sm-7">
                            <div class="dataTables_paginate paging_simple_numbers"
                                 id="datatable-responsive_paginate">
                                <ul class="pagination">
                                    <c:if test="${pageInfo.pageNum > 1}">
                                        <li class="paginate_button previous"><a
                                                href="javascript:page_nav(document.forms[0],1);"
                                                aria-controls="datatable-responsive" data-dt-idx="0"
                                                tabindex="0">首页</a>
                                        </li>
                                        <li class="paginate_button "><a
                                                href="javascript:page_nav(document.forms[0],${pageInfo.pageNum-1});"
                                                aria-controls="datatable-responsive" data-dt-idx="1"
                                                tabindex="0">上一页</a>
                                        </li>
                                    </c:if>
                                    <c:if test="${pageInfo.pageNum < pageInfo.totalPages}">
                                        <li class="paginate_button "><a
                                                href="javascript:page_nav(document.forms[0],${pageInfo.pageNum+1 });"
                                                aria-controls="datatable-responsive" data-dt-idx="1"
                                                tabindex="0">下一页</a>
                                        </li>
                                        <li class="paginate_button next"><a
                                                href="javascript:page_nav(document.forms[0],${pageInfo.totalPages});"
                                                aria-controls="datatable-responsive" data-dt-idx="7"
                                                tabindex="0">最后一页</a>
                                        </li>
                                    </c:if>
                                    <li>
                                        <button type="button" class="btn btn-primary" onclick="javascript:window.history.back(-1);">返回</button>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- /page content -->
<!-- footer content -->
<%@include file="/WEB-INF/jsp/teacher/common/footer.jsp" %>
<script src="${pageContext.request.contextPath }/statics/localjs/rollpage.js"></script>
<script src="${pageContext.request.contextPath }/statics/localjs/appinfolist.js"></script>
<script>

    function reset() {
        window.location.href = ${pageContext.request.contextPath}'/teacher/showStudent';
    }
</script>